<template>
	<view>
		<p-navbar title="收益"></p-navbar>
		<view class="title-flex">
			<!-- background-image: url(../../static/user/income1.png); -->
			<view class="flex-item" v-for="(item,index) in income" :key="index" :style="{'background-image':'url(../../static/user/income'+index+'.png)'}">
				<view class="flex1">{{item.val}}</view>
				<view class="flex2">{{fixled(form[item.key])}}</view>
			</view>
		</view>
		<view class="fooler" >
			<view>类型</view>
			<view style="color: #999999;">金额</view>
			<view style="color: #999999;">手续费</view>
			<view>时间</view>
		</view>
		<view class="fooler" v-for="(item,index) in countent" :key="index" @tap="router(item)" >
			<view>盈利</view>
			<view>{{fixled(item.profit)}}</view>
			<view>-{{fixled(item.fee)}}</view>
			<view>{{item.createTime}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show:false,
			countent:[
			],
			pages:1,
			form:{},
			data:true,
			income:[//今日累计收益
				{
					val:'今日收益',
					key:'todayProfit'
				},
				{
					val:'累计收益',
					key:'totalProfit'
				}
			]
			};
		},
		computed:{
			fixled(){
				return t=>{
					if(!t || t=='undefined') return '0.0000'
					return this.util.decimal(t)
				}
			}
		},
		onReachBottom() {
			this.pages++;
			this.OrderList()
		},
		onLoad() {
			this.request.post('order/getUSDTBalance').then(res=>{//今日累计收益
				this.form=res.data.data
				// this.$forceUpdate()
			})
			this.OrderList()
			
			
		},
		methods:{
			router(item){
				this.$Router.push({ path: '/pages/user/income-item',query:{type:JSON.stringify(item)}})
			},
			OrderList(){
				this.request.post({
					url: 'order/profitRecord',
					params : {
						pageSize:'20',
						page:this.pages
					}
				}).then(res=>{
					console.log(res.data.data)
					let data=res.data.data
					for(let i=0;i<data.length;i++){
						data[i].createTime=data[i].createTime.substring(0,10)
					}
					this.countent.push(...data)
				})
			},
		}
	}
</script>

<style lang="scss">
	.title-flex{
		display: flex;
		justify-content: space-between;
		align-items: center;
		// padding: 10rpx;
		.flex-item{
			background-image: url(../../static/user/income1.png);
			background-size: 100%;
			background-repeat: no-repeat;
			height: 160rpx;
			border-radius: 12rpx;
			padding: 10rpx 30rpx;
			margin: 20rpx 20rpx 0rpx;
			color: #FFFFFF;
			&.show{
				box-shadow: 0px 0px 12rpx 0rpx #2196F3;
			}
			.flex1{
				
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				line-height: 50rpx;
				color: rgba(#FFFFFF, 0.5);
			}
			.flex2{
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: 500;
				line-height: 50rpx;
				color: #FFFFFF;
				font-family: PingFang SC;
				font-weight: bold;
			}
		}
	}
	.fooler{
		// width: ;
		margin: 0rpx 25rpx;
		line-height: 90rpx;
		border-bottom: 1rpx solid rgba(153, 153, 153, 0.2);
		display: flex;
		justify-content: space-between;
		align-items: center;
		
		view:nth-child(1){
			width: 30%;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: bold;
			// line-height: 34px;
			color: #999999;
		}
		view:nth-child(2){
			width: 30%;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: bold;
			line-height: 34px;
			color: $light-color;
		}
		view:nth-child(3){
			width: 30%;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: bold;
			line-height: 34px;
			color: $light-color;
		}
		view:nth-child(4){
			
			font-size: 28rpx;
			font-family: PingFang SC;
			// font-weight: bold;
			line-height: 34px;
			color: #999999;
			text-align: right;
			width: 30%;
			
		}
	}
</style>
